#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#define MAX 66
using namespace std;

int main()
{
	int N = 0;
	scanf("%d", &N);

	int num[MAX];
	char arr[MAX][20];

	for (int i = 0; i < N; i++)
	{
		scanf("%d %s", &num[i], arr[i]);
	}

	int count = 0;
	for (int i = 0; i < N / 2; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			if (num[i] != num[j])
			{
				count++;
			}
			if (count == N / 2 - i)
			{
				printf("%s %s\n", arr[i], arr[j]);
				break;
			}
		}
		count = 0;
	}

	return 0;
}
